FROM osrf/ros:indigo-desktop-full

MAINTAINER LM <lm.91@qq.com>

# 更换源
RUN sudo sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && \
    sudo sed -i 's/packages.ros.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/ros-latest.list

RUN apt-get update ||:
RUN apt-get install -y openssh-server 
 
# 添加 ros 管理员用户，密码为 ros
RUN DOCKER_ENCRYPYTED_PASSWORD=`perl -e 'print crypt('"ros"', "aa"),"\n"'` && \
    useradd -m -d /home/ros -p $DOCKER_ENCRYPYTED_PASSWORD ros && \
    sed -Ei 's/adm:x:4:/ros:x:4:ros/' /etc/group && \
    adduser ros sudo && \
    chmod a=rx,u+ws /usr/bin/sudo

# 修复 PAM 与sshd 的登录
RUN sed -i 's/session    required     pam_loginuid.so/#session    required     pam_loginuid.so/g' /etc/pam.d/sshd && \
    echo '\n/etc/init.d/ssh start' >> /etc/rc.local && mkdir /var/run/sshd && \
    sed -i 's/X11Forwarding no/X11Forwarding yes/g' /etc/ssh/sshd_config

VOLUME /home/ros

EXPOSE 22
